using System;
using System.Windows.Forms;

namespace haxeProject {

	public class ProjectMenu : CommandBarMenu {

		public CommandBar main;
		public CommandBarButton mnew;
		public CommandBarButton open;
		public CommandBarButton close;
		public CommandBarButton build;
		public CommandBarButton test;
		public CommandBarButton buildTest;
		public CommandBarButton view;
		public CommandBarButton fview;

		public ProjectMenu( CommandBar main )
		{
			this.main = main;
			main.Items.Insert(4, this);

			view = new CommandBarButton("haXe Project");
			view.Image = Icons.PANEL.image;
			getMenu("ViewMenu").Items.Add(view);

			fview = new CommandBarButton("haXe Files");
			fview.Image = Icons.FPANEL.image;
			getMenu("ViewMenu").Items.Add(fview);

			mnew = new CommandBarButton("&New Project");
			mnew.Image = Icons.NEW.image;

			open = new CommandBarButton("&Open Project..");
			open.Image = Icons.OPEN.image;

			close = new CommandBarButton("&Close Project");
			close.Image = Icons.REMOVE.image;

			build = new CommandBarButton("&Build Project");
			build .Image = Icons.MENU_BUILD.image;

			test = new CommandBarButton("&Test Project");
			test.Image = Icons.MENU_TEST.image;
			
			buildTest = new CommandBarButton("&Build and Test");
			buildTest.Image = Icons.MENU_TESTBUILD.image;			

			base.Text = "&haXe";
			base.Items.Add(mnew);
			base.Items.Add(open);
			base.Items.Add(close);
			base.Items.AddSeparator();
			base.Items.Add(build);
			base.Items.Add(test);
			base.Items.Add(buildTest);

			/*
			// -- SHOW ICONS --
			int i;
			for(i=0;i<160;i++) {
				CommandBarButton b = new CommandBarButton(i.ToString());
				b.Image = Icons.Get(i).image;
				base.Items.Add(b);
			}			*/
		}

		private CommandBarMenu getMenu( String name ) {
			foreach( CommandBarMenu m in main.Items )
				if( m.Text == name || m.Name == name )
					return m;
			return null;
		}

		public bool enabled
		{
			set
			{
				CommandBarMenu p = getMenu("&Project");
				if( p != null ) p.IsVisible = !value;
				close.IsEnabled = value;
				test.IsEnabled = value;
				test.Shortcut = (value) ? Keys.F5 : Keys.None;
				build.IsEnabled = value;
				build.Shortcut = (value) ? Keys.F8 : Keys.None;
				buildTest.IsEnabled = value;
				buildTest.Shortcut = (value) ? Keys.Control | Keys.F5 : Keys.None;
			}
		}

	}
}
